package cn.com.anysdk.starter.config.oss;

import cn.com.anysdk.starter.aspect.OssLoggingAspect;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

@Configuration
@EnableAspectJAutoProxy
@EnableConfigurationProperties({
    AliyunOssProperties.class,
    LocalFileSystemProperties.class,
    OssLoggingConfiguration.class
})
public class OssAutoConfiguration {

    @Bean
    @ConditionalOnProperty(prefix = "anysdk.oss.logging", name = "enabled", havingValue = "true", matchIfMissing = true)
    public OssLoggingAspect ossLoggingAspect(OssLoggingConfiguration loggingConfig) {
        return new OssLoggingAspect(loggingConfig);
    }
}